import express from "express";
import api from "./service/api.js";
import upload from "./service/upload.js";
import bodyParser from "body-parser";

// Create http server
const app = express();

const logger = (req, res, next) => {
  console.log("params: ", req.params, "query: ", req.query, "body:", req.body);
  next();
};

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }))
app.use(logger);

app.use("/api/", api, upload);


const server = app.listen(4000, () => {
  const port = server.address().port;
  console.log(`Server started at http://localhost:${port}`);
});

